<form id="fenpei-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">分配方式:</label>
        <div class="col-xs-12 col-sm-8">

            <select name="types" id="getfenpeitype" class="form-control">
                <option  value="1" >部门</option>
                <option  value="2" >个人</option>
            </select>
        </div>
    </div>


    <div class="form-group" id="one" >
        <label class="control-label col-xs-12 col-sm-2">选择管理:</label>
        <div class="col-xs-12 col-sm-8">

            <select name="adminida" id="adminida" class="form-control">

                <option  value="" >请选择</option>
                {volist name="all" id="user"}
                <option  value="{$user.id}" >{$user.nickname}</option>
                {/volist}
            </select>

        </div>
    </div>

    <div class="form-group" id="ones" >
        <label class="control-label col-xs-12 col-sm-2">选择员工:</label>
        <div class="col-xs-12 col-sm-8" id="alluser">

        </div>
    </div>

    <div class="form-group" id="all" style="display: none">
        <label class="control-label col-xs-12 col-sm-2">选择员工:</label>
        <div class="col-xs-12 col-sm-8">

            <select name="adminidb" id="" class="form-control">
                {volist name="alluser" id="user"}
                <option  value="{$user.id}" >{$user.nickname}</option>
                {/volist}
            </select>

        </div>
    </div>


    <input class="form-control" name="ids" type="hidden" value="{$infos}">

    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-primary btn-embossed ">{:__('OK')}</button>
        </div>
    </div>
</form>

<script src="https://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>

    $("#getfenpeitype").change(function (){
       var value=$("#getfenpeitype").val();
       console.log(value);

       if (value==1){
           $("#one").show();
           $("#ones").show();
           $("#all").hide();


       }else {
           $("#one").hide();
           $("#ones").hide();
           $("#all").show();

       }

    })



    $("#adminida").change(function (){


        var id=$("#adminida").val();
        $("#alluser").html('');

        $.ajax({
            url:'facrm/thread/index/getdownuser',
            data:{'id':id},
            type:'post',
            dataType:'json',
            success:function (ret){
               var list=ret;
               var htaml='';
               list.forEach(function (index){
                   console.log(index)
                   htaml+="<input type='checkbox' name='allusers[]' style='margin-right: 4px'  value="+index.id+" name='useid'>" + index.nickname +"</input> <span style='margin-right: 20px'></span>";
               })

             $("#alluser").append(htaml)

            }
        })

        console.log(id)
    })





</script>